<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button id="btn1">测试1</button>
    <button class="1">测试2</button>
    <button>测试3</button>
    <button>测试4</button>
    <button>测试5</button>
    <button>测试6</button>
    <button>测试7</button>
    <button>测试8</button>
    <button>测试9</button>
    <button>测试10</button>

    <script>
        document.querySelectorAll('button').forEach(item => {
           item.onclick = () => {
            alert('测试')
        }
 
        }
 ) 
               document.querySelector('#btn1')
    </script>
  </body>
</html>
